home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / goodies / chromakeymovie / start.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  3.8 KB  |  180 lines

  1. /*
  2.     File:        start.c
  3.  
  4.     Contains:    
  5.  
  6.     Written by: Jason Hodges Harris        
  7.  
  8.     Copyright:    Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/28/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24.  
  25. // Mac Toolbox headers
  26.  
  27. #ifndef __DIALOGS__
  28. #include <Dialogs.h>
  29. #endif
  30.  
  31. #ifndef __FONTS__
  32. #include <Fonts.h>
  33. #endif
  34.  
  35. #ifndef __GESTALT__
  36. #include <Gestalt.h>
  37. #endif
  38.  
  39. #ifndef __MEMORY__
  40. #include <Memory.h>
  41. #endif
  42.  
  43. #ifndef __MENUS__
  44. #include <Menus.h>
  45. #endif
  46.  
  47. #ifndef __QDOFFSCREEN__
  48. #include <QDOffscreen.h>
  49. #endif
  50.  
  51. #ifndef __SEGLOAD__
  52. #include <SegLoad.h>
  53. #endif
  54.  
  55. #ifndef __TEXTEDIT__
  56. #include <TextEdit.h>
  57. #endif
  58.  
  59. #ifndef __TOOLUTILS__
  60. #include <ToolUtils.h>
  61. #endif
  62.  
  63. #ifndef __WINDOWS__
  64. #include <Windows.h>
  65. #endif
  66.  
  67.  
  68. // Program headers
  69.  
  70. #ifndef __CHROMAPPHEADER__
  71. #include "ChromaKeyMovie.h"
  72. #endif
  73.  
  74.  
  75. //    Global Variables
  76.  
  77. // Predefined RGBColors
  78.  
  79. RGBColor     kRGBWhite =    {0xFFFF,0xFFFF,0xFFFF},
  80.             kRGBBlack =    {0x0000,0x0000,0x0000},
  81.             gKeyColor;
  82. // Chroma keying mode
  83. short        gKeyMode;
  84. // location of the movie relative to the background image
  85. Boolean        gMovieBackGrnd;
  86. // Application loop exit test 
  87. Boolean        gDone;
  88. // Movie window open (only one window supported)
  89. Boolean        gMovieOpen;
  90.  
  91.  
  92.  
  93. // initialise the global variables
  94.  
  95. void InitGlobals(void)
  96. {
  97.     gKeyColor = kRGBBlack;        // preset chroma key color to black
  98.     gKeyMode = transparentMode;    // default Chroma key mode use transparent transfer mode
  99.     gMovieBackGrnd = false;        // movie in foreground
  100.     gDone = false;                // set global loop var to false while program active
  101.     gMovieOpen = false;            // No window open
  102. }
  103.  
  104.  
  105. // Gestalt tests
  106.  
  107. #pragma segment Main
  108. void TestforQuickTimeVersion(void)
  109. {
  110.     long    QTimeVersion;
  111.     OSErr    error;
  112.     if(Gestalt('qtim',&QTimeVersion) == noErr)
  113.     {
  114.              /* QuickTime version 2.1 or later required for all options to be available.
  115.                 If not display a warning dialog and disable QT 2.1 reliant feature */
  116.          if (QTimeVersion < 0x02100000)
  117.         {
  118.             DisplayAlert (rGenWarning,rQTmessages,2);
  119.             DisableItem(GetMenuHandle(mMode),iModifier); 
  120.         }
  121.  // check for the QuickTime shared library loaded as Gestalt not always correct
  122.  #if defined(powerc) || defined(__powerc)
  123.         if (!EnterMovies)
  124.         {
  125.             DisplayAlert(rGenAlert,rQTmessages,3);
  126.             gDone = true;
  127.             return;
  128.         }
  129. #endif
  130.         error = EnterMovies();    // initialise QuickTime
  131.         if (error != noErr)
  132.         {
  133.             DisplayAlert (rGenAlert,rQTmessages,1);
  134.             gDone = true;        // exit application
  135.         }
  136.         return;
  137.     }
  138.     DisplayAlert (rGenAlert,rQTmessages,1);
  139.     gDone = true;
  140.     return;
  141. }
  142.  
  143.  
  144. // Main function
  145.  
  146. #pragma segment Main
  147. int    main(void)
  148. {
  149.     long     *AppSize;                        // application size 
  150.     short    i;
  151.     
  152.     AppSize = (long*)(GetApplLimit());
  153.     SetApplLimit (AppSize-32768);
  154.  
  155.     // This decreases the application heap by 32k, which in turn
  156.     // increases the stack by 32k.
  157.  
  158.     MaxApplZone();    // Expand the heap so code segments load at the top.
  159.     for (i=0;i<5;i++)
  160.         MoreMasters();                // allocate more master pointers
  161.  
  162.     //      Initialise the toolbox
  163.  
  164.     InitGraf (&qd.thePort);
  165.     InitFonts();
  166.     InitWindows();
  167.     InitMenus();
  168.     TEInit();
  169.     InitDialogs(0L);
  170.     InitCursor();
  171.     
  172.     InitGlobals();                    // initialise globals
  173.     MenuBarInit();                    // init menubar
  174.     TestforQuickTimeVersion();        // test for and initialise Quicktime    
  175.     DoAdjustMenus();                 // menu setup
  176.     EventLoop();                    // Call the main event loop.
  177.     ExitToShell();                    // Quit the application.
  178.     return 0;
  179. }
  180.